﻿@using Blazor.Diagrams.Components
@using AntDesign
@using AntDesign.Core;
@using AntDesign.TableModels;
@using ERP.Workflow.Designer.BlazorUI.Components;
@using ERP.Workflow.Designer.BlazorUI.Domain;
@using ERP.Workflow.Designer.BlazorUI.Core
@using  ERP.Workflow.Designer.Domain.Shared.Localization;
@inject NotificationService  NotificationService;

<div @onmousedown:stopPropagation="true" 
 
style="@Style" class="@Class" >
     <Menu  Mode=MenuMode.Horizontal>
                      <MenuItem Key="sub1" OnClick="ClickTitle">  <Title Level="4">@Definition!.Name</Title> </MenuItem>
                      <MenuItem Key="sub2" OnClick="New" ><Icon Type="file-add" Theme="outline"/> @L["New"] </MenuItem>
                      <MenuItem Key="sub5" OnClick="Save" ><Icon Type="save" Theme="outline"/>@L["Save"] </MenuItem>
                      <MenuItem Key="sub6" OnClick="Refresh" ><Icon Type="reload" Theme="outline" />@L["Refresh"] </MenuItem>
                      <MenuItem Key="sub44" OnClick="todo"><Icon Type="import" Theme="outline"   />@L["Import"] </MenuItem>
                      <MenuItem Key="sub55" OnClick="todo"><Icon Type="export" Theme="outline"   />@L["Export"] </MenuItem>
                      <MenuItem Key="sub7" OnClick="todo"><Icon Type="border" Theme="outline"   />@L["RecSelect"] </MenuItem>
                      <MenuItem Key="sub8" OnClick="todo"><Icon Type="align-left" Theme="outline"  />@L["LeftAlign"] </MenuItem>
                      <MenuItem Key="sub9" OnClick="todo"><Icon Type="align-right" Theme="outline"  />@L["RightAlign"] </MenuItem>
                      <MenuItem Key="sub10" OnClick="todo"><Icon Type="eye" Theme="outline"  />@L["EyesView"] </MenuItem>
                      <MenuItem Key="sub10"   OnClick="todo"><Icon Type="form" Theme="outline"  />@L["FormDefinition"] </MenuItem>
     </Menu>
</div>             
  


@code {

    [Parameter] public string? Style{ get; set; }
    [Parameter] public string? Class{ get; set; }
    [CascadingParameter] public  Definition? Definition {get;set;}
    [Inject] IStringLocalizer<WorkflowDesignerResource> L{ get; set; }

    // public event Action<ClickTitleEventArg>? OnClickTitle;
    // public event Action<NewEventArg>? OnNew;
    // public event Action<SaveEventArg>? OnSave;
    // public event Action<RefreshEventArg>? OnRefresh;

    [Parameter] public EventCallback<ClickTitleEventArg> OnClickTitle { get; set; }
    [Parameter] public EventCallback<NewEventArg> OnNew{ get; set; }
        [Parameter] public EventCallback<SaveEventArg> OnSave{ get; set; }
            [Parameter] public EventCallback<RefreshEventArg> OnRefresh{ get; set; }
    public void SetTitle(string name)
    {
        Definition!.Name = name;
        StateHasChanged();
    }

        private void ClickTitle(MouseEventArgs e)
    {
        OnClickTitle!.InvokeAsync (new ClickTitleEventArg { Sender=this, Data=null, Event=e});
    }
    private void New(MouseEventArgs e)
    {
        OnNew!.InvokeAsync(new NewEventArg { Sender=this, Data=null, Event=e});
    }
    private void Save(MouseEventArgs e)
    {
        OnSave!.InvokeAsync(new SaveEventArg { Sender=this,Data=null, Event=e });
    }
    private void Refresh(MouseEventArgs e)
    {
        OnRefresh!.InvokeAsync(new RefreshEventArg { Sender = this, Data = null, Event = e });
    }

    private void todo()
    {
        NotificationService.Open(new NotificationConfig
            {

                Message = "提示！",
                Description = "Todo，现阶段流程设计器暂时只做能编辑节点设计流程并保存数据库，给流程审批必要的数据进行流转就可以了 ，锦上添花的事情待以后处理"
            });

    }

}
